package cn.element.io.nio.case1;

import java.net.ServerSocket;
import java.net.Socket;

/**
 * 实现伪异步通信架构
 */
public class Server {

    public static void main(String[] args) {
        try {
            ServerSocket server = new ServerSocket(8848);

            // 初始化一个线程池对象
            IServerPool pool = new IServerPool(3, 10);

            while (true) {
                Socket socket = server.accept();

                // 把Socket封装成任务对象
                Runnable target = new ServerRunnableTarget(socket);
                pool.execute(target);
            }
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

}
